package com.yq.cp.utils;

import java.security.SecureRandom;
import java.util.Random;

/**
 * 订单工具
 *
 * @author nico
 */
public class OrderNoUtil {

    private static final String SYMBOLS = "0123456789";
    private static final Random RANDOM = new SecureRandom();

    /**
     * 生成订单号 <br/>
     *
     * @return 订单号
     */
    public static synchronized String generateOrderNo() {
        char[] nonceChars = new char[6];
        for (int index = 0; index < nonceChars.length; ++index) {
            nonceChars[index] = SYMBOLS.charAt(RANDOM.nextInt(SYMBOLS.length()));
        }
        return "NS" + new String(nonceChars) + System.currentTimeMillis();
    }

}
